home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1999 July
/
Macworld (1999-07).dmg
/
Shareware World
/
Info
/
For Developers
/
Mops 3.4.sea
/
Mops source
/
Toolbox classes
/
Region
< prev
next >
Wrap
Text File
|
1995-11-23
|
2KB
|
100 lines
(*
Class Region is Mops implementation of QuickDraw structure Region.
Since Toolbox's region is a handle I've made it a subclass of Mops
Handle.
The class implements most ( but not all ) Toolbox calls pertinent for
the
region.
Gorazd Krosl, April 1995
*)
:Class Region super{ Handle }
:m New:
0 call NewRgn put: self ;m
:m Release:
get: self call DisposRgn ;m
:m MakeEmpty: get: self call SetEmptyRgn ;m
:m PutBounds: { l t r b -- }
get: self l t pack r b pack
call SetRectRgn ;m
:m PutRect: { r -- }
get: r putbounds: self ;m \ That's what Toolbox does with
\ RectRgn
:m Draw: get: self call FrameRgn ;m
:m Inset: \ ( dv dh -- )
pack get: self swap call InsetRgn ;m
:m Offset: \ ( dv dh -- )
pack get: self swap call OffsetRgn ;m
:m Paint: get: self call PaintRgn ;m
:m Invert: get: self call InvertRgn ;m
:m Update: get: self call InvalRgn ;m
:m Validate: get: self call ValidRgn ;m
:m Erase: get: self call EraseRgn ;m
:m GetBounds: \ ( - l t r b )
ptr: self 2+ get: rect ;m
(* *************** Operations on two regions *********************** *)
\ Following methods expect Mops region object on the stack. Second
operand
\ and destination are allways this region.
private
:m (rparams): { ^rgnobj -- srcA srcB dest }
get: ^rgnobj get: self dup ;m
public
\ UnionRgn
:m +: ( ^rgnObj -- )
(rparams): self call UnionRgn ;m
\ Take the difference of two regions.
:m -: ( ^rgnObj -- )
(rparams): self call DiffRgn ;m
\ Intersection
:m Sect: ( ^rgnObj -- )
(rparams): self call SectRgn ;m
\ Xor -> Take exclusive OR of two regions
:m Xor:
(rparams): self call XorRgn ;m
\ EqualRgn
:m =?: { ^rgnObj -- b }
word0 get: ^rgnObj get: self
call EqualRgn i->l ;m
\ CopyRgn
:m ->: { ^rgnObj -- }
(rparams): self drop call CopyRgn ;m
(* ******************* Queries *********************** *)
\ Point in region?
:m Point?: { ^mopsPt -- b }
word0 get: ^mopsPt pack get: self call PtInRgn i->l ;m
\ Contains rect
:m Rect?: { ^mopsRect -- b }
word0 addr: ^mopsRect get: self call RectInRgn i->l ;m
:m Empty?: \ ( -- b )
word0 get: self call EmptyRgn i->l ;m
;class